#coding=gbk

import os,re

FILENAME = 'index.html'
PATT = '<font size="4" color="blue">.*</font>'
a = '<font size="4" color="blue">'
b = '</font>'

if __name__ == '__main__':
    os.chdir(os.curdir)
    target = open(FILENAME,'w')
    content = ''''''
    for root,dir,files in os.walk(os.curdir):
      try:  
        for f in files:
            m = re.compile(PATT,re.M).search(open(f).read(),1)
            if m != None:
                caption = m.group(0)[len(a):-len(b)]
                if len(caption) <= 2:
                    caption = f
                content = content+"<li><a href='%s'>%s</a></li>\n"%(f,caption)
      except IOError:
          pass
    print content    
    target.write(content)
    target.close()
    print 'finished'